layui.config({
    base: "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index', 'form', 'jquery', 'table'], function () {
    var form = layui.form,
        table = layui.table,
        admin = layui.admin;


    table.render({
        elem: '#aliPay_mch_info_Manage'
        , url: '/alimchinfo/queryData'
        , method: "post"
        , height: 500
        , limit: 50	//显示数目
        , limits: [50, 100]
        , cols: [[
            {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left', hide: true}
            , {field: 'userName', width: 240, title: '用户名', "align": "center"}
            , {field: 'mobile', width: 130, title: '手机号', "align": "center"}
            , {field: 'agencyName', width: 130, title: '代理商', "align": "center"}
            , {
                field: 'status', width: 130, title: '状态', "align": "center", templet: function (obj) {
                    if (obj.status === 1) {
                        return "待处理";
                    } else if (obj.status === 2) {
                        return "审核中";
                    } else if (obj.status === 3) {
                        return "处理成功";
                    } else if (obj.status === 4) {
                        return "处理失败";
                    } else {
                        return "暂存待提交";
                    }
                }
            }
            , {field: 'message', width: 200, title: '上次提交备注信息', "align": "center"}
            , {field: 'updatedTime', width: 200, title: '提交时间', "align": "center"}
            , {field: 'OPT', width: 200, title: '操作', "align": "center", toolbar: "#OptData"}
        ]]
        , request: {
            pageName: 'pageNo' //页码的参数名称，默认：page
            , limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        where: {
            status: 1
        }
        , id: 'aliPay_mch_info_Manage'
        , page: true
    });


    /**
     * 处理进件
     */
    table.on('tool(aliPay_mch_info_Manage)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象

        if (layEvent === 'deal') {
            //向服务端发送删除指令
            layer.open({
                type: 2,
                title: '处理进件',
                shadeClose: true,
                resize: false,
                area: ['1600px', '800px'],
                content: '/alimchinfo/deal?id=' + data.id //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                , end: function () {
                    table.reload('aliPay_mch_info_Manage', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        , where: {}
                    });
                }
            });

        }
    });

    $(".search_btn").click(function () {

        table.reload('aliPay_mch_info_Manage', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            , where: {
                userName: $(".queryTable input[name='userName']").val(),
                agencyName: $(".queryTable input[name='agencyName']").val(),
                status: $(".queryTable select[name='status']").val()
            }
        });
    });

});



